package com.study.designmodes.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @author yangyanbin
 * @since 20221108
 **/
public enum InsuranceCategoryEnum {
    SOCINS("SOCINS", "社保"),
    MEDICAL("MEDICAL", "医保"),
    /**
     * 默认业务，实际业务中不会使用，用于通用的处理
     */
    DEFAULT("DEFAULT", "默认");

    private final String code;
    private final String name;

    public static InsuranceCategoryEnum getByName(String name) {
        InsuranceCategoryEnum[] var1 = values();
        int var2 = var1.length;

        for (int var3 = 0; var3 < var2; ++var3) {
            InsuranceCategoryEnum insuranceCategoryEnum = var1[var3];
            if (StringUtils.equals(insuranceCategoryEnum.getName(), name)) {
                return insuranceCategoryEnum;
            }
        }

        return null;
    }

    public static InsuranceCategoryEnum getByCode(String code) {
        InsuranceCategoryEnum[] var1 = values();
        int var2 = var1.length;

        for (int var3 = 0; var3 < var2; ++var3) {
            InsuranceCategoryEnum insuranceCategoryEnum = var1[var3];
            if (StringUtils.equals(insuranceCategoryEnum.getCode(), code)) {
                return insuranceCategoryEnum;
            }
        }

        return null;
    }

    public String getCode() {
        return this.code;
    }

    public String getName() {
        return this.name;
    }

    private InsuranceCategoryEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }
}